feat(sdk): add triggerConfig support to chat.headStart()#3916
Conversation
Handover-prepare session runs now accept the same tags, queue, and
session trigger options as chat.createStartSessionAction(), with
chat:{chatId} auto-prepended to tags.
Co-authored-by: Cursor <cursoragent@cursor.com>
🦋 Changeset detectedLatest commit: df96c66 The changes in this PR will be included in the next version bump. This PR includes changesets to release 25 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
WalkthroughThis PR adds optional ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Tools execution failed with the following error: Failed to run tools: 14 UNAVAILABLE: read ECONNRESET Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Hi @saasjesus, thanks for your interest in contributing! This project requires that pull request authors are vouched, and you are not in the list of vouched users. This PR will be closed automatically. See https://github.com/triggerdotdev/trigger.dev/blob/main/CONTRIBUTING.md for more details. |
| opts.idleTimeoutInSeconds ?? opts.triggerConfig?.idleTimeoutInSeconds ?? 60; | ||
|
|
||
| const userTags = opts.triggerConfig?.tags ?? []; | ||
| const tags = [`chat:${chatId}`, ...userTags].slice(0, 5); |
There was a problem hiding this comment.
🚩 Tag limit discrepancy: headStart uses 5 (correct), createStartSessionAction uses 10 (pre-existing issue)
The new headStart code at packages/trigger-sdk/src/v3/chat-server.ts:340 truncates tags with .slice(0, 5), which correctly matches the SessionTriggerConfig schema at packages/core/src/v3/schemas/api.ts:1577 (.max(5)). However, the analogous createStartSessionAction at packages/trigger-sdk/src/v3/ai.ts:9714 uses .slice(0, 10) with a comment saying "Platform cap is 10 tags per run" — that 10-tag cap applies to CreateSessionRequestBody.tags (line 1615), not triggerConfig.tags. If a customer passes >4 user tags through createStartSessionAction, the server would reject the request due to schema validation. The headStart code is the correct one; the pre-existing createStartSessionAction has a latent bug for users with many tags.
Was this helpful? React with 👍 or 👎 to provide feedback.
Summary
triggerConfigtochat.headStart()andchat.openSession(), threading it throughopenHandoverSessionintocreateSession.chat.createStartSessionAction(), auto-prependingchat:{chatId}to tags.idleTimeoutInSecondsstill wins overtriggerConfig.idleTimeoutInSeconds;handover-preparetrigger andchatIdinbasePayloadcannot be overridden by customer config.Test plan
cd packages/trigger-sdk && pnpm test src/v3/chat-server.test.ts --runchat:chat-1first) and queue oncreateSessionchat.headStart({ triggerConfig: { tags, queue } })and verify handover-prepare run appears with expected tags/queue in dashboardMade with Cursor